package com.nuit.cxl.ch2.controller;


import com.nuit.cxl.ch2.service.StudentService;
import com.nuit.cxl.ch2.service.impl.StudentServiceImpl;
import com.nuit.cxl.ch2.vo.Student;
import com.nuit.cxl.ch2.vo.StudentVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
//@RequestMapping("/")
public class StudentController {

    @Autowired
    StudentService studentService;
//    StudentServiceImpl studentServiceImpl;

    @RequestMapping("/student/{id}")
    public Student studentId(@PathVariable String id) {
//        System.out.println(student);
        Student student = studentService.getStudentById(Integer.parseInt(id));
        return student;
    }

    @RequestMapping("/student")
    public List<Student> getStudentByAge(@RequestParam Integer age){
//        System.out.println(student);
        List<Student> studentList = studentService.getStudentsByAge(age);
        return studentList;
    }
}
